using System.Collections.Generic;
using System.Xml.Linq;
using TickSharp.Core.Interfaces;
using TickSharp.Core.Interfaces.Repositories;
using TickSharp.Core.Model;

namespace TickSharp.Core.Infrastructure.Repositories
{
    public class UserRepository : RepositoryBase, IUserRepository
    {
        private readonly ISerializer<User> _serializer;

        public UserRepository(IApiConnectionInfo apiConnectionInfo, ISerializer<User> serializer) : base(apiConnectionInfo)
        {
            _serializer = serializer;
        }

        public IEnumerable<User> List()
        {
            string uri = BuildUrl("users", null);
            XElement elements = GetResponse(uri);
            return _serializer.Deserialize(elements);
        }
    }
}